package com.csw.mvc;

import java.util.Scanner;

public class UserController {
    public static void main(String[] args) {
        UserController userController = new UserController();
//        userController.login();
//        userController.register();
//        userController.modifyPassword();
        userController.delete();
    }

    public void login() {
        //1|用户输入用户名密码

        Scanner scanner = new Scanner(System.in);

        //用户输入用户名

        System.out.println("请输入用户名：");
        String username = scanner.next();


        //输入密码
        System.out.println("请输入密码：");
        String password = scanner.next();


        //调用业务层登录的方法
        UserService userService = new UserService();

        String login = userService.login(username, password);

        System.out.println(login);
    }


    public void register() {
        //1|用户输入用户名密码

        Scanner scanner = new Scanner(System.in);

        //用户输入用户名

        System.out.println("请输入用户名：");
        String username = scanner.next();


        //输入密码
        System.out.println("请输入密码：");
        String password = scanner.next();

        //确认密码密码
        System.out.println("请确认密码：");
        String nowPassword = scanner.next();


        UserService userService = new UserService();

        String register = userService.register(username, password, nowPassword);
        System.out.println(register);

    }

    public void modifyPassword() {

        //1|用户输入用户名密码

        Scanner scanner = new Scanner(System.in);

        //用户输入用户名

        System.out.println("请输入用户名：");
        String username = scanner.next();


        //输入密码
        System.out.println("请输入原密码：");
        String password = scanner.next();


        //输入密码
        System.out.println("请输入新密码：");
        String newPassword = scanner.next();

        //确认密码密码
        System.out.println("请确认密码：");
        String nowPassword = scanner.next();


        //调用业务层修改密码的方法
        UserService userService = new UserService();

        String s = userService.modifyPassword(username, password, newPassword, nowPassword);
        System.out.println(s);

    }
    public void delete(){
        //1|用户输入用户名密码

        Scanner scanner = new Scanner(System.in);

        System.out.println("请输入用户名：");
        String username = scanner.next();


        //输入密码
        System.out.println("请输入原密码：");
        String password = scanner.next();


        //输入密码
        System.out.println("请确认密码：");
        String nowPassword = scanner.next();

        //调用业务层注销的方法
        UserService userService = new UserService();

        String delete = userService.delete(username, password, nowPassword);

        System.out.println(delete);
    }
}
